/**
 * @author:ruimin
 * @date:2016年10月25日
 * @description:
 */
$(function () {   
	if(getUserRight()){
		if(userInfo.roleid.indexOf("cangpinchaxunyuan")==-1){
			alertFunc("对不起，你没有该系统权限");
			var userAgent = navigator.userAgent;
			if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") !=-1) {
			   window.top.location.href="about:blank";
			} else {
			   window.opener = null;
			   window.open("", "_top");
			   window.top.close();
			}			
			//return false;		    
		}
	}
	/*
  //获取藏品登记号查询条件
  var params_zdjh =$("#form_zdjh").serializeObject();

  //初始化总账列表Table
  createTable('#listtbl','antiques/zzquery.getZongZhangList.do','id',listtblColumns,params_zdjh);  
  
  //级联下拉框Id
  var doms_cpfl = ["DJH_CPFL1","DJH_CPFL2","DJH_CPFL3"];
  var doms_sd = ["DJH_SD1","DJH_SD2","DJH_SD3","DJH_SD4"];
  var doms_lb = ["LB_CPFL1","LB_CPFL2","LB_CPFL3"];
  var doms_kf = ["KF_CPFL1","KF_CPFL2","KF_CPFL3"];
  var doms_zd = ["ZDLB1","ZDLB2","ZD1"];
  //设置藏品类别级联下拉框
  selectThree(url_cplb,doms_cpfl);
  //设置时代级联下拉框
  selectFour(url_nd,doms_sd);
  //设置藏品类别级联下拉框
 // selectThree(url_cplb,doms_lb);
  //设置藏品类别级联下拉框
  //selectThree(url_cplb,doms_kf);
  //设置质地级联下拉框
  selectThree(url_zd,doms_zd);
  //设置来源类型下拉列表
  ajaxFunc("get",true,'antiques/sysmanage.getIdAndNameInJb.do?tableName=jb_lyfs',"",getSelectOptions,"LYLX");
  //设置质量范围下拉列表
  ajaxFunc("get",true,'antiques/sysmanage.getIdAndNameInJb.do?tableName=jb_zlfw',"",getSelectOptions,"ZLFW");
  //设置入藏时间范围下拉列表
  ajaxFunc("get",true,'antiques/sysmanage.getIdAndNameInJb.do?tableName=xtjb_rcsjfw',"",getSelectOptions,"RCSJFW");
  */
  //获取并填充保管部门
  /*var bgbmJson = ajaxResult("get",false,"antiques/sysmanage.getIdAndNameInjb.do",{'tableName':'jb_bgbm'});
  loadSelect("#form_fpkf select[name=bgbmid]",bgbmJson.rows,'id','name');*/
  //ajaxFunc("get",true,'antiques/sysmanage.getIdAndNameInjb.do?tableName=jb_bgbm',"",getSelectOptions,"BGBM");
/*
  //根据保管部门id获取并填充库房
	$('select[name=BGBM]').change(function(){
		var bgbmid = $(this).val();
		if(bgbmid !=null && bgbmid !=''){
			var kfJson = ajaxResult("get",false,"antiques/sysmanage.getkfIdNameBybgbmId.do",{'id':bgbmid});
			loadSelect("select[name=SZKF]",kfJson.rows,'kfid','kfmc');
		}
	});
  //生成图片列表
  var result = ajaxResult("post", false, "../resources/json/cangpin.json", "");
  var pageCount = caclPageCount(result.length,20);
  createPaginator("#page",'../resources/json/cangpin.json',1,pageCount,creatImgList);
  //creatImgList(".imglist");
  
  $(".imgtype").hide();
  
  //列表和图片切换
  $("#changeimg").click(function(){
	  var content = $("#changeimg")[0].src;
	  if(content.indexOf('imglist')>-1){
		  $(".listtype").hide();
		  $(".imgtype").show();
		  $("#changeimg").attr('src',"../resources/images/recordlist.png"); 
		  $("#changeimg").attr('title',"列表显示"); 
	  }else{
		  $(".listtype").show();
		  $(".imgtype").hide();
		  $("#changeimg").attr('src',"../resources/images/imglist.png"); 
		  $("#changeimg").attr('title',"图片显示"); 
	  }
  });
  
  //点击藏品登记查询-查询按钮
  $("#queryBtn_zdjh").click(function(){
	  var params_zdjh = $("#form_zdjh").serializeObject();   
	  $("#listtbl").bootstrapTable('refresh',{query:params_zdjh});
  });
  //点击藏品类别-查询按钮
  $("#queryBtn_lb").click(function(){
	  var params_lb = $("#form_lb").serializeObject(); 
	  $("#listtbl").bootstrapTable('refresh',{query:params_lb});
  });
  //点击藏品库房-查询按钮
  $("#queryBtn_kf").click(function(){
	  var params_kf = $("#form_fk").serializeObject();
	  $("#listtbl").bootstrapTable('refresh',{query:params_kf});
  });*/
})
/*
//总账列表table表头
var listtblColumns=[{
    checkbox: true
  }, {
    field: 'ZDJH',
    title: '总登记号'
  }, {
    field: 'FLH',
    title: '分类号'
  }, {
    field: 'CPMC',
    title: '名称',
    formatter: function(value, row, index) {
  	  return '<a href="query/cangPinDetail.html?zdjh='+row.ZDJH+'&page=../home.html">'+value+'</a>';
  	}
  }, {
    field: '',
    title: '藏品分类',
    formatter: function(value, row, index){
    	if(row.CPFL3!="")
    		return row.CPFL3;
    	else if(row.CPFL3=="" && row.CPFL2!="")
    		return row.CPFL2;
    	else
    		return row.CPFL1;
    }
  }, {
    field: 'SJSL',
    title: '实际数量'
  }, {
    field: 'LYMS',
    title: '来源'
  }];

//生成图片列表
function creatImgList(data){
	var tHtml = "";
	if(data != null){
		$.each(data,function(index,value){
			tHtml += "<div>";
			tHtml += "<a href='zongZhangDetail.html'><img src='../resources/images/"+value["daiBiaoYingXiang"]+"'></a>";
			tHtml += "<p><a href='zongZhangDetail.html'>"+value["mingCheng"]+"</a></p>";
			tHtml += "</div>";
		});
	}
	$(".imglist").html(tHtml);
}
*/